package com.lzx.iteam.adapter;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import com.lzx.iteam.R;
import com.lzx.iteam.util.ImageLoaderInterface;
import io.rong.imageloader.core.DisplayImageOptions;
import io.rong.imageloader.core.ImageLoader;
import io.rong.imageloader.core.assist.ImageScaleType;

import java.util.ArrayList;

/**
 * Created by zhangshuai on 15-2-8.
 */
public class ImageAdpter extends BaseAdapter {

    private ArrayList<String> mList;
    private Context mContext;
    private LayoutInflater mInflater;

    public ImageAdpter(Context mContext, ArrayList<String> mList){
        this.mContext = mContext;
        this.mList = mList;
        mInflater = LayoutInflater.from(mContext);
    }

    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public Object getItem(int i) {
        return mList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int position, View view, ViewGroup viewGroup) {
        if (view == null){
            view = mInflater.inflate(R.layout.adapter_grid_item,viewGroup,false);
        }
        ImageView imageView = (ImageView) view.findViewById(R.id.AdapterGridItemTwoImage);
        if(mList != null){
            if(mList != null && position<mList.size()){
                    ImageLoaderInterface.imageLoader.displayImage("file://" + mList.get(position), imageView, ImageLoaderInterface.optionGalleryImage);
            }
        }
        return view;

    }
}
